# -*- coding: utf-8 -*-
"""
API文档定义
"""

SIMPLE_DOC = {
    "tags": ["仪表盘"],
    "summary": "API接口",
    "description": "API接口说明",
    "responses": {
        "200": {
            "description": "请求成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "操作成功"},
                    "data": {"type": "object"}
                }
            }
        }
    }
}


SIMPLE_DOC = {
    "tags": ["API"],
    "summary": "API接口",
    "description": "API接口说明",
    "responses": {
        "200": {
            "description": "请求成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "操作成功"},
                    "data": {"type": "object"}
                }
            }
        }
    }
}

# 为兼容性创建通用别名
CREATE_ORDER_DOC = SIMPLE_DOC
GET_ORDER_LIST_DOC = SIMPLE_DOC
GET_ORDER_DETAIL_DOC = SIMPLE_DOC
UPDATE_ORDER_DOC = SIMPLE_DOC
DELETE_ORDER_DOC = SIMPLE_DOC
CANCEL_ORDER_DOC = SIMPLE_DOC
GET_USER_ORDERS_DOC = SIMPLE_DOC

# 管理员相关
ADMIN_GET_ORDER_LIST_DOC = SIMPLE_DOC
ADMIN_UPDATE_ORDER_DOC = SIMPLE_DOC
ADMIN_DELETE_ORDER_DOC = SIMPLE_DOC
ADMIN_ORDER_STATS_DOC = SIMPLE_DOC

# 活动相关
CREATE_ACTIVITY_DOC = SIMPLE_DOC
GET_ACTIVITY_LIST_DOC = SIMPLE_DOC
GET_ACTIVITY_DETAIL_DOC = SIMPLE_DOC
UPDATE_ACTIVITY_DOC = SIMPLE_DOC
DELETE_ACTIVITY_DOC = SIMPLE_DOC
JOIN_ACTIVITY_DOC = SIMPLE_DOC

# 支付相关
CREATE_PAYMENT_DOC = SIMPLE_DOC
PAYMENT_NOTIFY_DOC = SIMPLE_DOC
GET_PAYMENT_STATUS_DOC = SIMPLE_DOC

# 横幅相关
GET_BANNER_LIST_DOC = SIMPLE_DOC
CREATE_BANNER_DOC = SIMPLE_DOC
UPDATE_BANNER_DOC = SIMPLE_DOC
DELETE_BANNER_DOC = SIMPLE_DOC

# 管理员相关
ADMIN_LOGIN_DOC = SIMPLE_DOC
GET_ADMIN_INFO_DOC = SIMPLE_DOC

# 仪表盘相关
GET_DASHBOARD_STATS_DOC = {
    "tags": ["仪表盘"],
    "summary": "获取仪表盘统计数据",
    "description": "获取系统总体统计数据，包括用户数、订单数、场馆数等",
    "responses": {
        "200": {
            "description": "获取统计数据成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "example": 200,
                        "description": "状态码"
                    },
                    "message": {
                        "type": "string",
                        "example": "获取成功",
                        "description": "响应消息"
                    },
                    "data": {
                        "type": "object",
                        "description": "统计数据",
                        "properties": {
                            "totalUsers": {
                                "type": "integer",
                                "example": 1250,
                                "description": "总用户数"
                            },
                            "totalOrders": {
                                "type": "integer",
                                "example": 3420,
                                "description": "总订单数"
                            },
                            "totalVenues": {
                                "type": "integer",
                                "example": 25,
                                "description": "总场馆数"
                            },
                            "totalRevenue": {
                                "type": "number",
                                "example": 125600.50,
                                "description": "总收入"
                            },
                            "todayOrders": {
                                "type": "integer",
                                "example": 45,
                                "description": "今日订单数"
                            },
                            "todayRevenue": {
                                "type": "number",
                                "example": 3200.00,
                                "description": "今日收入"
                            },
                            "weeklyOrders": {
                                "type": "integer",
                                "example": 285,
                                "description": "本周订单数"
                            },
                            "weeklyRevenue": {
                                "type": "number",
                                "example": 18750.00,
                                "description": "本周收入"
                            },
                            "monthlyOrders": {
                                "type": "integer",
                                "example": 1150,
                                "description": "本月订单数"
                            },
                            "monthlyRevenue": {
                                "type": "number",
                                "example": 67800.00,
                                "description": "本月收入"
                            }
                        }
                    }
                }
            }
        },
        "401": {
            "description": "未授权",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 401},
                    "message": {"type": "string", "example": "未授权访问"}
                }
            }
        }
    }
}

# 获取收入图表数据接口文档
GET_REVENUE_CHART_DOC = {
    "tags": ["仪表盘"],
    "summary": "获取收入图表数据",
    "description": "获取指定时间范围内的收入趋势数据",
    "parameters": [
        {
            "name": "period",
            "in": "query",
            "type": "string",
            "required": False,
            "description": "时间周期：7d=最近7天，30d=最近30天，90d=最近90天",
            "example": "30d",
            "default": "30d"
        },
        {
            "name": "start_date",
            "in": "query",
            "type": "string",
            "required": False,
            "description": "开始日期，格式：YYYY-MM-DD",
            "example": "2024-01-01"
        },
        {
            "name": "end_date",
            "in": "query",
            "type": "string",
            "required": False,
            "description": "结束日期，格式：YYYY-MM-DD",
            "example": "2024-01-31"
        }
    ],
    "responses": {
        "200": {
            "description": "获取收入图表数据成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "example": 200,
                        "description": "状态码"
                    },
                    "message": {
                        "type": "string",
                        "example": "获取成功",
                        "description": "响应消息"
                    },
                    "data": {
                        "type": "object",
                        "description": "收入图表数据",
                        "properties": {
                            "period": {
                                "type": "string",
                                "example": "30d",
                                "description": "查询周期"
                            },
                            "chartData": {
                                "type": "array",
                                "description": "图表数据点",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "date": {
                                            "type": "string",
                                            "example": "2024-01-15",
                                            "description": "日期"
                                        },
                                        "revenue": {
                                            "type": "number",
                                            "example": 2350.00,
                                            "description": "当日收入"
                                        },
                                        "orderCount": {
                                            "type": "integer",
                                            "example": 35,
                                            "description": "当日订单数"
                                        }
                                    }
                                }
                            },
                            "totalRevenue": {
                                "type": "number",
                                "example": 67800.00,
                                "description": "总收入"
                            },
                            "avgDailyRevenue": {
                                "type": "number",
                                "example": 2260.00,
                                "description": "日均收入"
                            },
                            "growth": {
                                "type": "object",
                                "description": "增长数据",
                                "properties": {
                                    "percentage": {
                                        "type": "number",
                                        "example": 15.6,
                                        "description": "增长百分比"
                                    },
                                    "trend": {
                                        "type": "string",
                                        "example": "up",
                                        "description": "增长趋势：up=上升，down=下降，stable=稳定"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

# 获取订单图表数据接口文档
GET_ORDER_CHART_DOC = {
    "tags": ["仪表盘"],
    "summary": "获取订单图表数据",
    "description": "获取指定时间范围内的订单趋势数据",
    "parameters": [
        {
            "name": "period",
            "in": "query",
            "type": "string",
            "required": False,
            "description": "时间周期：7d=最近7天，30d=最近30天，90d=最近90天",
            "example": "30d",
            "default": "30d"
        }
    ],
    "responses": {
        "200": {
            "description": "获取订单图表数据成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "example": 200,
                        "description": "状态码"
                    },
                    "message": {
                        "type": "string",
                        "example": "获取成功",
                        "description": "响应消息"
                    },
                    "data": {
                        "type": "object",
                        "description": "订单图表数据",
                        "properties": {
                            "period": {
                                "type": "string",
                                "example": "30d",
                                "description": "查询周期"
                            },
                            "chartData": {
                                "type": "array",
                                "description": "图表数据点",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "date": {
                                            "type": "string",
                                            "example": "2024-01-15",
                                            "description": "日期"
                                        },
                                        "totalOrders": {
                                            "type": "integer",
                                            "example": 35,
                                            "description": "总订单数"
                                        },
                                        "completedOrders": {
                                            "type": "integer",
                                            "example": 32,
                                            "description": "已完成订单数"
                                        },
                                        "cancelledOrders": {
                                            "type": "integer",
                                            "example": 3,
                                            "description": "已取消订单数"
                                        }
                                    }
                                }
                            },
                            "orderStats": {
                                "type": "object",
                                "description": "订单统计",
                                "properties": {
                                    "totalOrders": {
                                        "type": "integer",
                                        "example": 1150,
                                        "description": "总订单数"
                                    },
                                    "completedRate": {
                                        "type": "number",
                                        "example": 91.3,
                                        "description": "完成率百分比"
                                    },
                                    "cancellationRate": {
                                        "type": "number",
                                        "example": 8.7,
                                        "description": "取消率百分比"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

# 获取订单趋势数据接口文档
GET_ORDER_TREND_DOC = {
    "tags": ["仪表盘"],
    "summary": "获取订单趋势数据",
    "description": "获取订单趋势分析数据，包括各种状态的订单分布",
    "parameters": [
        {
            "name": "type",
            "in": "query",
            "type": "string",
            "required": False,
            "description": "趋势类型：daily=日趋势，weekly=周趋势，monthly=月趋势",
            "example": "daily",
            "default": "daily"
        }
    ],
    "responses": {
        "200": {
            "description": "获取订单趋势数据成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "example": 200,
                        "description": "状态码"
                    },
                    "message": {
                        "type": "string",
                        "example": "获取成功",
                        "description": "响应消息"
                    },
                    "data": {
                        "type": "object",
                        "description": "订单趋势数据",
                        "properties": {
                            "type": {
                                "type": "string",
                                "example": "daily",
                                "description": "趋势类型"
                            },
                            "trendData": {
                                "type": "array",
                                "description": "趋势数据",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "period": {
                                            "type": "string",
                                            "example": "2024-01-15",
                                            "description": "时间段"
                                        },
                                        "pending": {
                                            "type": "integer",
                                            "example": 5,
                                            "description": "待支付订单数"
                                        },
                                        "paid": {
                                            "type": "integer",
                                            "example": 28,
                                            "description": "已支付订单数"
                                        },
                                        "completed": {
                                            "type": "integer",
                                            "example": 32,
                                            "description": "已完成订单数"
                                        },
                                        "cancelled": {
                                            "type": "integer",
                                            "example": 3,
                                            "description": "已取消订单数"
                                        }
                                    }
                                }
                            },
                            "summary": {
                                "type": "object",
                                "description": "汇总信息",
                                "properties": {
                                    "totalPeriods": {
                                        "type": "integer",
                                        "example": 30,
                                        "description": "总时间段数"
                                    },
                                    "averageOrders": {
                                        "type": "number",
                                        "example": 38.3,
                                        "description": "平均订单数"
                                    },
                                    "peakPeriod": {
                                        "type": "string",
                                        "example": "2024-01-20",
                                        "description": "峰值时间段"
                                    },
                                    "peakOrders": {
                                        "type": "integer",
                                        "example": 65,
                                        "description": "峰值订单数"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

# 其他可能缺失的仪表盘相关
GET_USER_GROWTH_DOC = SIMPLE_DOC
GET_VENUE_STATS_DOC = SIMPLE_DOC

# 场馆预约相关
GET_VENUE_BOOKINGS_DOC = SIMPLE_DOC

# 最近订单相关
GET_RECENT_ORDERS_DOC = SIMPLE_DOC